<?
include_once "accesscontrol.php";
require('thumbnail_party.class.php');

if (isset($_POST[s1]))
{
	
	if(!empty($_FILES[images][name]))
	{
				$NewImageName = $_FILES[images][name];
				copy($_FILES[images][tmp_name], "re_images/".$NewImageName);
	}
	else{
				$NewImageName = $_POST[img];
	}
	
			$thumb =& new thumbnail_party();
			$thumb->set_cache_path(NULL);
			$thumb->set_imagemagick_path(NULL);	
			$thumb->set_source_file ('re_images/'.$NewImageName);
			$thumb->set_output_type ('jpg');
			//$thumb->set_background ('#ffffff');
			$thumb->intJPEGQuality = 85;
			$thumb->set_thumbnail_size (70, 40);
			$thumb->output('cache/images/'.$NewImageName);			
	
	$q1 = "update job_employer_info set
		epass = \"$_POST[epass]\", 
		ContactName = '$_POST[ContactName]',
		position = '$_POST[position]',
		CompanyLogo = '$NewImageName',
		YearEstablished = '$_POST[YearEstablished]',
		website = '$_POST[web]',
		capital = '$_POST[capital]',
		employees = '$_POST[employees]',
		CompanyName = \"$_POST[CompanyName]\", 
		CompanyProfile = \"$_POST[CompanyProfile]\", 
		CompanyCountry = \"$_POST[CompanyCountry]\", 
		CompanyState = \"$_POST[CompanyState]\",
		CompanyZip = \"$_POST[CompanyZip]\", 
		CompanyCity = \"$_POST[CompanyCity]\",
		street = \"$_POST[street]\",
		CompanyAddress = \"$_POST[CompanyAddress]\", 
		CompanyPhone = \"$_POST[CompanyPhone]\", 
		CompanyPhone2 = \"$_POST[CompanyPhone2]\", 
		fax = \"$_POST[fax]\",
		CompanyEmail = \"$_POST[CompanyEmail]\"
		
		where ename = '$_SESSION[ename]' ";


		$r1 = mysql_query($q1);

		if(!mysql_error())
		{
			echo "<center><span class=TNA>Your information was changed successfully!</span></center>";
		}

}

//get the employer info
$q1 = "select * from job_employer_info where ename = '$_SESSION[ename]' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);

?>


<span class=HeaderClass>Employer Info</span><br><br><br>

<script>

function CheckEmployer() {

	if(document.f1.ContactName.value=="")
	{
		alert('Enter a contact name, please!');
		document.f1.ContactName.focus();
		return false;
	}

	if(document.f1.position.value=="")
	{
		alert('Select your position, please!');
		document.f1.position.focus();
		return false;
	}

	if(document.f1.CompanyName.value=="")
	{
		alert('Enter your company name, please!');
		document.f1.CompanyName.focus();
		return false;
	}

	if(document.f1.CompanyCountry.value=="")
	{
		alert('Select your company country, please!');
		document.f1.CompanyCountry.focus();
		return false;
	}

	if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.f1.CompanyEmail.value))
	{
		alert("Invalid E-mail Address! Please re-enter.");
		document.f1.CompanyEmail.value="";
		document.f1.CompanyEmail.focus();
		return false;
	}

	if(document.f1.epass.value=="")
	{
		alert('Enter your password, please!');
		document.f1.epass.focus();
		return false;
	}

	if(document.f1.cpass.value=="")
	{
		alert('Confirm your password, please!');
		document.f1.cpass.focus();
		return false;
	}

	if(document.f1.epass.value != "" && document.f1.cpass.value != "" && document.f1.epass.value != document.f1.cpass.value)
	{
		alert('Enter and confirm your password again!');
		document.f1.epass.value="";
		document.f1.cpass.value="";
		document.f1.epass.focus();
		return false;
	}

}

</script>

<form method=post onsubmit="return CheckEmployer();" name=f1 enctype="multipart/form-data">
<table width=600 border=0 align=center cellpadding="3" cellspacing=0 class=BlackText>
<caption align=center class=HeaderClass>Edit your info</caption>

<tr>
	<td colspan=2 class="row1 BlackLink"><strong>Company details</strong></td>
</tr>

<tr>
	<td width=150 align=left>Contact name<font color=red>*</font></td>
	<td width=370><input type=text name=ContactName value="<?=$a1[ContactName]?>"></td>
</tr>

<tr>
	<td align=left>Position<font color=red>*</font></td>
	<td>
		<select name="position">
              <option value="Owner" <? if($a1[position] == "Owner") { echo "selected"; } ?>>Owner</option>
              <option value="Director" <? if($a1[position] == "Director") { echo "selected"; } ?>>Director</option>
              <option value="HR Director" <? if($a1[position] == "HR Director") { echo "selected"; } ?>>HR Director</option>
              <option value="HR Manager" <? if($a1[position] == "HR Manager") { echo "selected"; } ?>>HR Manager</option>
              <option value="HR Assistant" <? if($a1[position] == "HR Assistant") { echo "selected"; } ?>>HR Assistant</option>
        </select>
	</td>
</tr>

<tr>
	<td align=left></td>
	<td>
	<img src="re_images/<?=$a1[CompanyLogo]?>" width="150" height="200"><input type="hidden" id="img" name="img" value="<?=$a1[CompanyLogo]?>" /><br>
		<a href=delete_image.php?file=<?=$a1[CompanyLogo]?>>delete</a>
	</td>
</tr>

<tr>
<td align=left>
<label for="images">Change Logo:</label></td>
	<td><input type=file name="images" id="images"></td>
</tr>

<tr>
	<td align=left>Company name (legal)<font color=red>*</font></td>
	<td><input type=text name=CompanyName value="<?=$a1[CompanyName]?>"></td>
</tr>

<tr>
	<td align=left valign="top">Company Profile</td>
	<td><textarea rows=6 cols=35 name=CompanyProfile style="width:350px"><?=$a1[CompanyProfile]?></textarea></td>
</tr>

<tr>
	<td align=left>Year Established</td>
	<td><input type=text name=YearEstablished size=5 maxlength=4 value="<?=$a1[YearEstablished]?>"></td>
</tr>

<tr>
	<td align=left>Website</td>
	<td><input type=text name=web value="<?=$a1[website]?>"></td>
</tr>

<tr>
	<td align=left>Reg. capital</td>
	<td><input type=text name=capital value="<?=$a1[capital]?>" size=10></td>
</tr>

<tr>
	<td align=left>No. employees</td>
	<td><input type=text name=employees size=10 maxlength=10 value="<?=$a1[employees]?>"></td>
</tr>

<tr>
	<td colspan=2 class="row1 BlackLink"><strong>Company address</strong></td>
</tr>

<tr>
	<td align=left>Address</td>
	<td><input type=text name=CompanyAddress value="<?=$a1[CompanyAddress]?>"></td>
</tr>

<tr>
	<td align=left>Street</td>
	<td><input type=text name=street value="<?=$a1[street]?>"></td>
</tr>

<tr>
	<td align=left>Town/city</td>
	<td><input type=text name=CompanyCity value="<?=$a1[CompanyCity]?>"></td>
</tr>

<tr>
	<td align=left>State/County/Province:</td>
	<td><input type=text name=CompanyState value="<?=$a1[CompanyState]?>"></td>
</tr>

<tr>
	<td align=left>Country:<font color=red>*</font></td>
	<td><?=select_country($a1[CompanyCountry], "CompanyCountry");?></td>
</tr>

<tr>
	<td align=left>Zip/Postal code</td>
	<td><input type=text name=CompanyZip value="<?=$a1[CompanyZip]?>"></td>
</tr>

<tr>
	<td align=left>Telephone</td>
	<td><input type=text name=CompanyPhone value="<?=$a1[CompanyPhone]?>"></td>
</tr>

<tr>
	<td align=left>Mobile number</td>
	<td><input type=text name=CompanyPhone2 value="<?=$a1[CompanyPhone2]?>"></td>
</tr>

<tr>
	<td align=left>Fax number</td>
	<td><input type=text name=fax value="<?=$a1[fax]?>"></td>
</tr>

<tr>
	<td align=left>E-mail<font color=red>*</font></td>
	<td><input type=text name=CompanyEmail size=34 value="<?=$a1[CompanyEmail]?>"></td>
</tr>

<tr>
	<td colspan=2 class="BlackLink row1"><strong>Login details</strong></td>
</tr>

<tr>
	<td align=left valign=middle>Username </td>
	<td><b><?=$a1[ename]?></b></td>
</tr>

<tr>
	<td align=left>Password<font color=red>*</font></td>
	<td><input type=password name=epass maxlength=10> max. 10 symbols</td>
</tr>

<tr>
	<td align=left>Confirm password<font color=red>*</font></td>
	<td><input type=password name=cpass maxlength=10></td>
</tr>

<tr>
	<td align="left">&nbsp;</td>
	<td align=left><input type=submit name=s1 value="Update"></td>
</tr>
	
</table>
	
</form>



<? include_once('../footer.php'); ?>